package cn.stylefeng.guns.modular.demo.controller.convert;

import cn.stylefeng.guns.dao.entity.GaiaBatchInfo;
import cn.stylefeng.guns.dao.entity.Goods;
import cn.stylefeng.guns.dao.entity.SaleStock;
import cn.stylefeng.guns.dao.entity.Supplier;
import cn.stylefeng.guns.modular.demo.controller.domain.GoodsVO;
import cn.stylefeng.guns.modular.demo.controller.domain.SaleStockVO;
import cn.stylefeng.guns.modular.demo.controller.domain.SaleVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.Objects;

@Mapper(componentModel = "spring")
public interface SaleStockConverter extends BaseConverter {
    @Mapping(source = "supplier.name", target = "supplierName")
    @Mapping(source = "supplier.supplierCode", target = "supplierCode")
    @Mapping(source = "saleStock.supplierId", target = "supplierId")
    @Mapping(source = "goods.commodityName", target = "commodityName")
    @Mapping(source = "goods.commodityCode", target = "commodityCode")
    @Mapping(source = "saleStock.price", target = "price")
    @Mapping(source = "saleStock.stoCode", target = "storeCode")
    @Mapping(source = "gaiaBatchInfo.batExpiryDate", target = "batExpireDate")
//    @Mapping(source = "gaiaBatchInfo.batBatchNo", target = "batch")
    @Mapping(source = "gaiaBatchInfo.batProductDate", target = "batProductDate")
    SaleStockVO conver(SaleStock saleStock, Goods goods, Supplier supplier, GaiaBatchInfo gaiaBatchInfo);

    @Mapping(source = "supplier.name", target = "supplierName")
    @Mapping(source = "supplier.supplierCode", target = "supplierCode")
    @Mapping(source = "saleStock.supplierId", target = "supplierId")
    @Mapping(source = "goods.commodityName", target = "commodityName")
    @Mapping(source = "goods.commodityCode", target = "commodityCode")
    @Mapping(source = "saleStock.price", target = "price")
    @Mapping(source = "saleStock.stoCode", target = "storeCode")
    @Mapping(source = "gaiaBatchInfo.batExpiryDate", target = "batExpireDate")
    SaleVO converSaleVo(SaleStock saleStock, Goods goods, Supplier supplier, GaiaBatchInfo gaiaBatchInfo);


}
